package alipay.openplatform.edu.campus.jiuye.api.utils;/**
 * Created by zhangyang on 26/8/2016.
 */

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 上下文工具
 *
 * @author zhangyang
 * @create 2016-08-26
 */
public class ContextUtils {
    public static final String SESSIONUTILS = "SessionUtils";

    //    public static UserBaseInfo getUserInfo(final HttpServletRequest request) {
//        HttpSession session=request.getSession();
//        if (session==null) return null;
//
//        if (session.getAttribute(SESSIONUTILS) == null) {
//            session.invalidate();
//            return null;
//        } else {
//            return (UserBaseInfo) session.getAttribute(SESSIONUTILS);
//        }
//    }
    public static String getUserId(final HttpServletRequest request) {
        HttpSession session = request.getSession();
        if (session == null) return null;

        if (session.getAttribute(SESSIONUTILS) == null) {
            session.invalidate();
            return null;
        } else {
            return (String) session.getAttribute(SESSIONUTILS);
        }
    }


}
